#include "vm.h"
#include "utils.h"
#include "common.h"
#include "core.h"

void init_vm(VM *vm)
{
    vm->allocated_bytes = 0;
    vm->cur_parser = NULL;
    vm->string_class = NULL;
    String_buffer_init(&vm->all_method_names);
    vm->all_modules = new_objMap(vm);
}

VM* new_vm(void )
{
    VM *vm = (VM *)malloc(sizeof(VM));
    if (vm == NULL)
    {
        MEM_ERROR("allocate VM failed!");
    }
    init_vm(vm);
    build_core(vm);
    return vm;
}